function [ Price, Error ] = q4AT( M  )
%Q4 Summary of this function goes here
%   Implementation of MC method using Standard constructions
%   Apply Antithetic Variance Reduction

if nargin < 1
    M = 10000; end

% Parameters
S0 = 100; K = 100; r = 0.05; sigma = 0.3;
N = 32; 
T = 1;
dt = 1/N;
disc = exp(-r*T);

% Standard Construction
Wt = randn(M ,N);
Wt_t = -Wt;
factor = exp((r-0.5*sigma^2)*dt + sigma*sqrt(dt)*Wt);
St = S0*cumprod(factor,2);
factor = exp((r-0.5*sigma^2)*dt + sigma*sqrt(dt)*Wt_t);
St_t = S0*cumprod(factor,2);

%St_bar = (St + St_t)/2;

Payoff = max(mean(St,2)-K,0);
Payoff_hat = max(mean(St_t,2)-K,0);

Price = disc*mean(0.5*(Payoff+Payoff_hat));

Error = sqrt(var(0.5*(Payoff+Payoff_hat)));


end

